﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace Light.Utility
{
    /// <summary>
    /// 摘要:
    /// 　　指示一个属性可用于搜索。
    /// </summary>
    [Serializable]
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    [ComVisible(true)]
    public sealed class SearchableAttribute : Attribute
    {
        private int _displayIndex = int.MaxValue;
        private string _displayName = string.Empty;
        private string _propertyName = string.Empty;
 


        /// <summary>
        /// 初始化新实例
        /// </summary>
        public SearchableAttribute()
            : base()
        {
        }

        /// <summary>
        /// 初始化新实例
        /// </summary>
        /// <param name="displayName">显示名称</param>
        public SearchableAttribute(string displayName)
            : base()
        {
            this.DisplayName = displayName;
        }

        /// <summary>
        /// 初始化新实例
        /// </summary>
        /// <param name="displayName">显示名称</param>
        /// <param name="propertyName">搜索的属性名，默认为当前属性名</param>
        public SearchableAttribute(string displayName, string propertyName)
            : base()
        {
            this.DisplayName = displayName;
            this.PropertyName = propertyName;
        }

        /// <summary>
        /// 显示的查询属性描述名称
        /// </summary>
        public string DisplayName
        {
            get { return this._displayName; }
            set { this._displayName = value; }
        }

        public int DisplayIndex
        {
            get { return _displayIndex; }
            set { _displayIndex = value; }
        }

        /// <summary>
        /// 搜索的属性名，默认为当前属性名
        /// </summary>
        public string PropertyName
        {
            get { return _propertyName; }
            set { _propertyName = value; }
        }
    }
}